//
//  XKNewsHtmlController.m
//  XKJF
//
//  Created by Mr.xu on 2017/1/6.
//  Copyright © 2017年 xiaokang100. All rights reserved.
//

#import "XKNewsHtmlController.h"

@interface XKNewsHtmlController () <UIWebViewDelegate>

@end

@implementation XKNewsHtmlController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIWebView *webView = [[UIWebView alloc] init];
    [webView setFrame:CGRectMake(0, 0, Main_Width, Main_Height - 64)];
    webView.scrollView.bounces = NO;
    webView.delegate = self;
    [webView loadHTMLString:self.htmlString baseURL:nil];
    
    [MobClick event:@"NewsLook"];
    
    [self.view addSubview:webView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSString *js = @"function imgAutoFit() { \
    var imgs = document.getElementsByTagName('img'); \
    for (var i = 0; i ( imgs.length; ++i) { \
    var img = imgs[i]; \
    img.style.maxWidth = %f; \
    } \
    }";
    
    js = [NSString stringWithFormat:js, [UIScreen mainScreen].bounds.size.width - 20];
    
    [webView stringByEvaluatingJavaScriptFromString:js];
    [webView stringByEvaluatingJavaScriptFromString:@"imgAutoFit()"];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}



@end
